﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb;

public partial class MainPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        InitMenu();
    }
    //用于初始化菜单数据.
    private void InitMenu()
    {
        string menuHTML = "<table>";
        DBOperate myDB = new DBOperate();
        myDB.SetCommandString("Select * from ChapterList");
        OleDbDataReader dbReader = myDB.ExecuteReader();
        //开始读取数据初始化菜单
        while (dbReader.Read())
        {
            //判断CNo这个字段是否为空，如果不为空值就在no和name之间插入换行符
            //menuHTML += string.Format("<tr><a href=\"javascript:alert('{2}')\"><td>{0}{1}</td></a></tr>",
            //                        dbReader["CNo"] != DBNull.Value ? dbReader["CNo"].ToString() + "<br />" : "",
            //                        dbReader["CName"].ToString(),
            //                        dbReader["No"]);
            menuHTML += string.Format("<tr><td onclick=\"SetFrameContent('{2}');\">{0}{1}</td></tr>",
                                    dbReader["CNo"] != DBNull.Value ? dbReader["CNo"].ToString() + "<br />" : "",
                                    dbReader["CName"].ToString(),
                                    dbReader["No"]);

        }
        menuHTML += "</table>";
        LMenu.InnerHtml = menuHTML;
    }
}
